package sync02;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer2 {

    public static void main(String[] args) throws Exception {
        // 创建生产者
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer("producer_pethome_group");
        // 设置调用均衡
        defaultMQProducer.setNamesrvAddr("127.0.0.1:9876");
        // 启动producer
        defaultMQProducer.start();
        // 设置文本消息
        Message message = new Message("pethome_topic", "pethome_tags", "第二遍的家庭作业,MQQQQQQ".getBytes(StandardCharsets.UTF_8));
        // 发送消息
        defaultMQProducer.send(message);
        // 关系生产者
        defaultMQProducer.shutdown();
    }

}
